// Main interpreter for ABaCus code

#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include "parse-abc.cpp"

using namespace std;

char fname[256];
program prog;
char c = 'a';

void openFile( char * );

int main (int argv, char * argc[], char * envc[])
{
   if ( argv > 1 ) { openFile(argc[1]); }
   else
   {
      cout << "No filepath provided in command line. Enter filepath: ";
      cin.getline(fname,256);
      openFile(fname);
   }
   
   prog.purge();
   prog.debug(); // run any changes to code
   prog.print(); // display program for read check
   prog.parse();
}

void openFile( char * fname )
{
   FILE * file;

   file = fopen(fname, "r");
   
   while ( c != EOF )
   {
      c = getc(file);
      if ( c != EOF ) { prog.push_back(c); }
   }
   
   fclose(file);
}
